//
//  LSResetPasswardVController.m
//  LookScore
//
//  Created by wr on 2017/12/16.
//  Copyright © 2017年 ChongQingXunTiCompany. All rights reserved.
//

#import "LSResetPasswardVController.h"
#import "LSHttpEnclosureTool.h"
#import "MBProgressHUD+MJ.h"
@interface LSResetPasswardVController ()

@property (weak, nonatomic) IBOutlet UITextField *resetPasswardTF;
@property (weak, nonatomic) IBOutlet UIButton *sureBu;
@end

@implementation LSResetPasswardVController
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:YES];
    self.navigationController.navigationBar.translucent = NO;
}

- (void)viewDidLoad {
    [super viewDidLoad];
     self.title=@"忘记密码";
    self.resetPasswardTF.keyboardType=UIKeyboardTypeASCIICapable;
    self.resetPasswardTF.secureTextEntry = YES;
    
    [self.sureBu setBackgroundImage:[CommonClass getImageWithBgColor:LSSubColor7ec5fd] forState:UIControlStateNormal];
    [self.sureBu setBackgroundImage:[CommonClass getImageWithBgColor:LSNavMainColor] forState:UIControlStateHighlighted];
}
- (IBAction)isOpenEyes:(UIButton *)sender {
    
    sender.selected=!sender.selected;
    self.resetPasswardTF.secureTextEntry = sender.selected;
}
- (IBAction)sureRevamp:(UIButton *)sender {
    if (self.resetPasswardTF.text.length<6 || self.resetPasswardTF.text.length > 15){
        [MBProgressHUD showOnlyMessage:@"请输入6-15位的密码" afterDelay:1.5f];
    }else if ([self isEmpty:self.resetPasswardTF.text]) {
        [MBProgressHUD showOnlyMessage:@"密码中不能含有空格字符" afterDelay:1.5f];
    }else if(self.resetPasswardTF.text.length >= 6 && self.resetPasswardTF.text.length <= 15){
        NSDictionary *findPwdDic=@{@"validataCode":self.verificationString,@"mobile":self.mobileString,@"pwd":self.resetPasswardTF.text};
        [LSHttpEnclosureTool POST:LSUserFindPwd parameters:findPwdDic resBlock:^(id responseObject) {
            if (responseObject) {
                [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"passwordString"];
                [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"select"];
                [self.navigationController popToRootViewControllerAnimated:YES];
            }
        }];
    }
}

-(BOOL)isEmpty:(NSString *) str {
    NSRange range = [str rangeOfString:@" "];
    if (range.location != NSNotFound) {
        return  YES; //yes代表包含空格
    }else {
        return  NO;  //反之
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
